import { IPSApplication } from '../ipsapplication';
import { IPSAppViewMsg } from './ipsapp-view-msg';
import { IPSAppViewMsgGroupDetail } from './ipsapp-view-msg-group-detail';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppViewMsgGroupDetailImpl extends PSModelObjectImpl implements IPSAppViewMsgGroupDetail {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappviewmsg: IPSAppViewMsg | null = null;

  getPSAppViewMsg(): IPSAppViewMsg | null {
    if (this.psappviewmsg != null) return this.psappviewmsg;
    const value = this.M.getPSAppViewMsg;
    if (value == null) {
      return null;
    }
    const ipsapplication = this.getParentPSModelObject('app.IPSApplication') as IPSApplication;
    if (ipsapplication != null) {
      this.psappviewmsg = ipsapplication.findPSAppViewMsg(value);
    }
    return this.psappviewmsg;
  }

  get psAppViewMsg(): IPSAppViewMsg | null {
    return this.getPSAppViewMsg();
  }

  getPSAppViewMsgMust(): IPSAppViewMsg {
    const value = this.getPSAppViewMsg();
    if (value == null) {
      throw new Error('未指定应用视图消息');
    }
    return value;
  }

  get position(): 'TOP' | 'BOTTOM' | 'BODY' | 'POPUP' | 'CUSTOM' {
    return this.M.position;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSAppViewMsgGroupDetailImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.view.IPSAppViewMsgGroupDetail' || cls == 'view.IPSViewMsgGroupDetail') return true;
    return super.instanceof(cls);
  }
}
